package ly;

import aloha.activity.NavActivity;
import aloha.base.Application;
import aloha.lv.Disp;
import aloha.lv.Obj;
import aloha.lv.Size;
import aloha.lv.Disp.DeviceInfo;

class MyDisp extends Disp {
    HomeActivity activity;
    public MyDisp(int w, int h) {
        super(w, h);
    }
    public boolean onKeyEvent(int keyCode, boolean pressed) {
        return activity.onKeyEvent(keyCode, pressed);
    }
}

public class Main {
    static Application app;
    public static void main(String paths[]) {
        Application app = new Application();
        String path = app.getBundlePath() + "/assets/icon";
        System.out.println("BundlePath:" + path);
        Main.app = app;
        Disp.init();
        Size size = new Size();
        size.w = 400;
        size.h = 500;
        DeviceInfo info = Disp.getDeviceInfo();
        if (info.haveFixedSize) {
            size.w = info.preferSize.w;
            size.h = info.preferSize.h;
        } else {
            size.w = Math.min(size.w, info.maxiumSize.w);
            size.h = Math.min(size.h, info.maxiumSize.h);

            size.w = Math.max(size.w, info.miniumSize.w);
            size.h = Math.max(size.h, info.miniumSize.h);
        }
        System.out.println("creat window size " + size.w + "  " + size.h);
        MyDisp disp = new MyDisp(size.w, size.h);
        disp.show();
        Obj root = disp.getLayerSys();

        HomeActivity home = new HomeActivity();
        disp.activity = home;
        NavActivity navActivity = new NavActivity(home);
        System.out.println("home:" + home + "  nav:" + navActivity);
        navActivity.window = root;
        navActivity.onCreate();
        navActivity.onShow();


        app.run();
    }
}